package com.springcloud3.controller;



import com.springcloud3.config.Person;
import com.springcloud3.config.Sheep;
import com.springcloud3.vo.User;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

//@Slf4j
@RestController
@Tag(name = "hello接口", description = "hello相关的 API 接口")
public class HelloController {
    private static final Logger logger =  LoggerFactory.getLogger(HelloController.class);
    @Operation(summary = "获取用户信息接口", description = "通过用户ID获取用户信息")


    @GetMapping("/hello/{id}")
    public String hello( @Parameter(description = "用户唯一标识", required = true)
                             @PathVariable("id") Long id ) {
     //  int s=10/0;
        logger.warn("fafafa");
        return "hello ,Spring boot 3";
    }

    @Operation(summary = "人添加接口", description = "添加接口")
    @PostMapping("/hello/ha")
    public User createUser(@RequestBody User user) {
        //模拟数据库保存用户并返回用户ID主键
        user.setAge(1);
        return user;
    }

    /**
     * 1.默认对象写入json,因为默认web场景导入jackson处理json的包
     * 2.jackson也支持把数据写为xml,导入xml相关依赖
     * accept application/json ,text/xml ,text/yaml
     * @return
     */
    @GetMapping("/hello/sheep")
    public Sheep sheep() {
        Sheep sheep=new Sheep();
     sheep.setId(12313l);
     sheep.setName("da sheep");
     return sheep;

    }
}
